﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式之禅.模板方法模式
{
    public abstract class Product
    {
        public abstract string Start();
        public abstract string Stop();
        protected virtual bool IsStop()
        {
            return false;
        }
        public string Rest()
        {
            string result = string.Empty;
            result+=this.Start();
            if (this.IsStop())
                result += this.Stop();
            return result;
        }
    }

    public class ProductA : Product
    {
        public override string Start()
        {
            return "A-Start ";
        }
        public override string Stop()
        {
            return "A-Stop ";
        }
    }
    public class ProductB : Product
    {
        public override string Start()
        {
            return "B-Start ";
        }
        public override string Stop()
        {
            return "B-Stop ";
        }
        protected override bool IsStop()
        {
            return true;
        }
    }



}
